import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { viteMockServe } from 'vite-plugin-mock'

// https://vite.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  plugins: [
    vue(),
    viteMockServe({
      mockPath: 'mock',
      enable: process.env.USE_MOCK === 'true',
      logger: true
    })],
  server: {
    proxy: {
      '/passport': {
        target: 'http://127.0.0.1:8080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/passport/, '')
      }
    }
  },
  define: {
    'process.env.USE_MOCK': true
  }
})
